# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=erofs-utils
pkgver=1.7.1
pkgrel=1
pkgdesc="Userspace utilities for linux-erofs file system"
arch=(loong64 x86_64)
url="https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git"
license=(
  Apache-2.0
  GPL-2.0-or-later
)
depends=(
  glibc
  lz4
  zlib
)
makedepends=(
  fuse2
  util-linux
  xz
)
optdepends=(
  'fuse2: for erofsfuse'
)
source=($url/snapshot/$pkgname-$pkgver.tar.gz)
sha512sums=('f5fc08d8d70e3e06c06aaa5a36e9b16ca1ff7c722fc88dba1f5c46fa86914be02e45e948c59504bd0fd4a3a4050ad7a27a5da2657ffbf40ec20ef0d1bfb832ff')
b2sums=('0d7954d57a7755b4efa566ae2cca443ab15178e02d403cadec7b2e867582044ec4191963c54dac6c0637e428649f5898e0ed921f4a3c5461234a455e609ef5a8')

prepare() {
  cd $pkgname-$pkgver
  autoreconf -fiv
}

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr --enable-fuse --enable-lzma
  make
}

check() {
  make -k check -C $pkgname-$pkgver
}

package() {
  depends+=(
    util-linux libuuid.so
    xz liblzma.so
  )

  make DESTDIR="$pkgdir/" install -C $pkgname-$pkgver
  install -vDm 644 $pkgname-$pkgver/{AUTHORS,ChangeLog,README} -t "$pkgdir/usr/share/doc/$pkgname/"
}
